import { Column, Entity, Index } from "typeorm";

@Index("sys_operation_log_template_pkey", ["id"], { unique: true })
@Entity("sys_operation_log_template", { schema: "public" })
export class SysOperationLog {
    @Column("bigint", { primary: true, name: "id" })
    id!: string;

    @Column("character varying", { name: "module", length: 100 })
    module!: string;

    @Column("character varying", { name: "type", length: 20 })
    type!: string;

    @Column("character varying", { name: "action", length: 100 })
    action!: string;

    @Column("bigint", { name: "operator_id", nullable: true })
    operatorId!: string | null;

    @Column("character varying", {
        name: "request_url",
        nullable: true,
        length: 255,
    })
    requestUrl!: string | null;

    @Column("character varying", {
        name: "request_method",
        nullable: true,
        length: 10,
    })
    requestMethod!: string | null;

    @Column("jsonb", { name: "request_data", nullable: true })
    requestData!: object | null;

    @Column("jsonb", { name: "response_data", nullable: true })
    responseData!: object | null;

    @Column("jsonb", { name: "old_data", nullable: true })
    oldData!: object | null;

    @Column("character varying", {
        name: "ip_address",
        nullable: true,
        length: 50,
    })
    ipAddress!: string | null;

    @Column("character varying", {
        name: "user_agent",
        nullable: true,
        length: 255,
    })
    userAgent!: string | null;

    @Column("timestamp without time zone", {
        name: "created_at",
        nullable: true,
        default: () => "CURRENT_TIMESTAMP",
    })
    createdAt!: Date | null;
}
